package com.example.demo.vo.task;

import com.example.demo.po.task.Task;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;

import java.time.Instant;
import java.time.LocalDateTime;
import java.time.ZoneId;
import java.util.Date;

@Data
public class TaskVO {
    private int tid;
    private String doc;
    private String intro;
    private int type;
    private String title;
    private int state=-1;
    @JsonFormat( pattern = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime startTime;
    @JsonFormat( pattern = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime endTime;
    private int workerNum;
    private int currentWorkerNum;
    private String appFile;
    private int aid;
    private String username;
    private int difficulty;
    private int device;
    private double similarity;

    public TaskVO(){
    }

    public TaskVO(Task task){
        tid = task.getTid();
        doc = task.getDoc();
        intro = task.getIntro();
        type = task.getType();
        title = task.getTitle();
        state = task.getState();
        startTime = task.getStartTime();
        endTime = task.getEndTime();
        workerNum = task.getWorkerNum();
        currentWorkerNum = task.getCurrentWorkerNum();
        difficulty=task.getDifficulty();
        device=task.getDevice();
    }
    //pojo(vo,po,dto)不能有业务逻辑，这个方法不能暴露给外界
    private LocalDateTime toLocalDateTime(Date date){
        Instant instant = date.toInstant();
        return instant.atZone(ZoneId.systemDefault()).toLocalDateTime();
    }

}


